package com.xingfly;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.ErrorPage;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@SpringBootApplication
@EnableTransactionManagement
public class XingFlyApplication {

	public static void main(String[] args) {
		SpringApplication.run(XingFlyApplication.class, args);
	}

	@Bean
	public EmbeddedServletContainerCustomizer containerCustomizer(){
		return (container->{
			ErrorPage errorPage403 =  new ErrorPage(HttpStatus.FORBIDDEN, "/403");
			ErrorPage errorPage404 =  new ErrorPage(HttpStatus.NOT_FOUND, "/404");
			ErrorPage errorPage500 =  new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/404");
			container.addErrorPages(errorPage403,errorPage404,errorPage500);
		});
	}
}
